<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 定义个构造函数
    function Father(uname,age){
      this.uname = uname;
      this.age = age;
    }
    // 定义在原型方法
    Father.prototype.money=function(){
      console.log('小目标');
    }
    // 修改this指向  继承 father 此时this 指向 实例对象son
    function Son(uname,age){
      Father.call(this,uname,age);
    }
   //把Father的实例化对象给了Son(覆盖)
    Son.prototype=new Father()
     //将Son.prototype的constructor属性指回Son构造函数
    Son.prototype.constructor=Son;
       //给Son.prototype添加新的方法
    Son.prototype.study=function(){
      console.log('好好学习');
    }
    const father=new Father('zs',18)
    const son=new Son('ls',22)
    console.log(son);
    son.money()
    son.study()
    father.study()
  </script>
</body>
</html>